# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Maintainer:  Andrzej Giniewicz <gginiu@gmail.com>

pkgname=linuxconsole
pkgver=1.8.1
pkgrel=1
pkgdesc="Set of utilities for joysticks and serial devices"
arch=('loong64' 'x86_64')
url="https://sourceforge.net/projects/linuxconsole/"
license=('GPL')
makedepends=('sdl2')
provides=('joystick' 'inputattach')
replaces=('joystick' 'inputattach')
optdepends=('sdl2: for ffmvforce utility')
backup=('etc/conf.d/inputattach')
validpgpkeys=('79D9C58C50D6B5AA65D530C1759778A9A36B494F')
source=(https://prdownloads.sourceforge.net/linuxconsole/linuxconsoletools-$pkgver.tar.bz2{,.sig}
	'inputattach.conf.d'
	'inputattach.service'
	'inputattachctl')
sha256sums=('4da29745c782b7db18f5f37c49e77bf163121dd3761e2fc7636fa0cbf35c2456'
            'SKIP'
            '3807b2b34bea40c6d6036629ac3eaee31b44549c81fac62e922eb6524f0b203e'
            '3fe8df1d4330ad95a02206946440576ad3a56230d43107f1d703bff077182f84'
            '908e3a6cec41bd4fbe7066fb54213a80c96d91b219ca045399a54e65c0995c8c')

prepare() {
  cd "${srcdir}"/linuxconsoletools-$pkgver
  sed -i 's|lib/udev|usr/lib/udev|g' utils/Makefile
}

build() {
  cd "${srcdir}"/linuxconsoletools-$pkgver
  make PREFIX=/usr
}

package() {
  cd "${srcdir}"/linuxconsoletools-$pkgver
  make PREFIX=/usr DESTDIR="${pkgdir}" install

  install -Dm755 "$srcdir"/inputattachctl "$pkgdir"/usr/bin/inputattachctl
  install -Dm644 "$srcdir"/inputattach.conf.d "$pkgdir/etc/conf.d/inputattach"
  install -Dm644 "$srcdir"/inputattach.service "$pkgdir"/usr/lib/systemd/system/inputattach.service
}
